﻿namespace Agile.Service.Admin.WebApi.Controllers;

/// <summary>
/// 系统角色服务接口
/// </summary>
[Route("api/[controller]/[action]")]
[ApiController]
public class SysRoleController : AgileControllerBase
{
    /// <summary> 添加角色 </summary> 
    [HttpPost]
    public async Task<ResponseResult<bool>> Insert(InsertSysRoleRequest request)
    => Result(await this.GetService<ISysRoleService>().InsertAsync(request));

    /// <summary> 修改角色 </summary> 
    [HttpPost]
    public async Task<ResponseResult<bool>> Update(UpdateSysRoleRequest request)
    => Result(await this.GetService<ISysRoleService>().UpdateAsync(request));

    /// <summary> 禁用/启用 </summary> 
    [HttpGet]
    public async Task<ResponseResult<bool>> Enabled(long roleID, bool enabled)
    => Result(await this.GetService<ISysRoleService>().EnabledAsync(roleID, enabled));

    /// <summary> 删除角色 </summary> 
    [HttpGet]
    public async Task<ResponseResult<bool>> Remove(long roleID)
    => Result(await this.GetService<ISysRoleService>().RemoveAsync(roleID));

    /// <summary> 查询角色 </summary> 
    [HttpPost]
    public async Task<ResponseResult<List<QuerySysRoleResponse>>> Query(QuerySysRoleRequest request)
    => Result(await this.GetService<ISysRoleService>().QueryAsync(request));
}
